package mobi.hami.huapin.dao;

import mobi.hami.huapin.daobase.CrudMapper;
import mobi.hami.huapin.model.UserWechat;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;
import org.springframework.stereotype.Repository;

import java.util.List;
@Repository
public interface UserWechatMapper extends CrudMapper<UserWechat> {

    @Select("select * from user_wechat where wechat_small_id = #{wechat_small_id} LIMIT 1")
    UserWechat selectByWechatSmallId(@Param("wechat_small_id")String wechat_small_id);

    /**
     * 根据用户Id　更新拼团参与次数
     * @param id
     * @return
     */
    @Update("update user_wechat set partack_collage_count=ifnull(partack_collage_count,0)+1 where user_id=#{id}")
    int updatePartackCollageByUserId(Integer id);

    /**
     * 根据用户Id　更新发起拼团次数
     * @param id
     * @return
     */
    @Update("update user_wechat set launch_collage_count=ifnull(launch_collage_count,0)+1 where user_id=#{id}")
    int updateLaunchCollageByUserId(Integer id);

    /**
     * 根据用户Id　更新个人拼团次数
     * @param id
     * @return
     */
    @Update("update user_wechat set self_collage_count=ifnull(self_collage_count,0)+1 where user_id=#{id}")
    int updateselfCollageByUserId(Integer Id);


    /**
     * 根据用户Id获取微信信息
     * @param id
     * @return
     */
    @Select("select * from user_wechat where user_id=#{id}")
    UserWechat findModelbyUserId(Integer id);

    @Select("select * from user_wechat where user_id in (${ids})")
    List<UserWechat> findListbyUserIds(@Param("ids") String ids);
}